package Reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Test {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("Reflect.Person");
        Object obj = cls.newInstance();
        Method[] methods = cls.getDeclaredMethods();
        for (Method method : methods) {
            String name = method.getName();
            System.out.println(method.getName());
            if (
                    method.getParameterCount() == 0 &&
                    method.getModifiers() == Modifier.PUBLIC &&
                    name.contains("e")
            ) {
                method.setAccessible(true);
                method.invoke(obj);
            }
        }


    }


}
